package com.anyext.storage.mapping.impl;

import java.util.HashMap;
import java.util.Map;

import com.anyext.storage.dialect.Dialect;
import com.anyext.storage.jdbc.RowCallback;
import com.anyext.storage.mapping.CustomSql;

@SuppressWarnings("serial")
public class CustomSqlImpl implements CustomSql {

	private String				identity;

	private String				group;

	private Dialect				dialect;

	private Map<String, String>	paramAlias	= new HashMap<String, String>();

	private String				customSql;

	private Class<?>			rowCallback;

	@Override
	public String getIdentity() {
		return identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}

	@Override
	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	@Override
	public Dialect getDialect() {
		return dialect;
	}

	public void setDialect(Dialect dialect) {
		this.dialect = dialect;
	}

	@Override
	public Map<String, String> getParamAlias() {
		return paramAlias;
	}

	public void setParamAlias(Map<String, String> paramAlias) {
		this.paramAlias = paramAlias;
	}

	@Override
	public String getCustomSql() {
		return customSql;
	}

	public void setCustomSql(String customSql) {
		this.customSql = customSql;
	}

	@Override
	@SuppressWarnings("unchecked")
	public <E> RowCallback<E> getRowCallback() {
		try {
			return (RowCallback<E>) rowCallback.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void setRowCallback(Class<?> rowCallback) {
		this.rowCallback = rowCallback;
	}

}
